package com.example.langchaindemo.tools;

import com.example.langchaindemo.pojo.Reservation;
import com.example.langchaindemo.service.ReservationService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class ReservationTool {
    @Autowired
    private ReservationService reservationService;
    @Tool("预约志愿填报服务")
    public void insert(@P("考生姓名") String name,
                       @P("考生性别") String gender,
                       @P("考生电话号码")String phone,
                       @P("预约时间，格式为：yyyy-MM-dd'T'HH:mm")String communicationTime,
                       @P("考生所在省份")String province,
                       @P("考生分数")Integer estimateScore){
        Reservation reservation = new Reservation(null, name, gender, phone, LocalDateTime.parse(communicationTime), province, estimateScore);
        reservationService.insert(reservation);
    }
    @Tool("查询预约信息服务")
    public Reservation selectByPhone(@P("考生电话号码")String phone){
        return reservationService.selectByPhone(phone);
    }
}
